<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('雇员工种统计列表')"/>
</head>
<body class="gray-bg">


<div class="ui-layout-center">
    <ul class="nav nav-tabs">
        <li role="presentation"><a th:href="@{/system/user/common_edit/{userId}(userId=${userId})}">用户基本信息</a></li>
        <li role="presentation"><a th:href="@{/bajiaostar/detail/edit/{userId}(userId=${userId})}">用户详情</a></li>
        <li role="presentation"><a th:href="@{/bajiaostar/coupon/{userId}(userId=${userId})}">我的优惠卷</a></li>
        <li role="presentation"><a th:href="@{/bajiaostar/collect/2/{userId}(userId=${userId})}">我收藏的零工</a></li>
        <li role="presentation"><a th:href="@{/bajiaostar/collect/0/{userId}(userId=${userId})}">我收藏的雇主</a></li>
        <li role="presentation"><a th:href="@{/bajiaostar/collect/1/{userId}(userId=${userId})}">我收藏的雇员</a></li>
        <li role="presentation"><a th:href="@{/bajiaostar/black/{userId}(userId=${userId})}">黑名单</a></li>
        <li role="presentation"><a th:href="@{/bajiaostar/flow/myflow/{userId}(userId=${userId})}">我的流水</a></li>
        <li role="presentation"><a th:href="@{/bajiaostar/flow/myflowpingfen/{userId}(userId=${userId})}">我的评分</a></li>
        <li role="presentation"><a th:href="@{/system/user/sub_user/{userId}(userId=${userId})}">我的下级</a></li>
        <li role="presentation"><a th:href="@{/bajiaostar/draw/}">提现列表</a></li>
        <li role="presentation"><a th:href="@{/bajiaostar/event/}">邀请管理</a></li>
        <li role="presentation" class="active"><a href="#">工种统计</a></li>
    </ul>
    <div class="container-div">
        <form id="user-form">
            <input type="hidden" name="userId" th:value="${userId}"/>
        </form>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
</div>

<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('bajiaostar:taskCateUser:edit')}]];
    var addFlag = [[${@permission.hasPermi('bajiaostar:taskCateUser:add')}]];
    var removeFlag = [[${@permission.hasPermi('bajiaostar:taskCateUser:remove')}]];
    var prefix = ctx + "system/user";

    $(function () {
        var options = {
            url: prefix + "/my_cate",
            updateUrl: prefix + "/taskCateUserEdit/{id}",
            modalName: "雇员工种统计",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'cateId',
                    title: '工种ID',
                    visible: false
                },
                {
                    field: 'cateName',
                    title: '工种'
                },
                {
                    field: 'cateNum',
                    title: '工作次数'
                },
                {
                    field: 'cateComment',
                    title: '评价次数'
                },
                {
                    field: 'cateGood',
                    title: '好评次数'
                },
                {
                    field: 'cateGoodRate',
                    title: '好评率',
                    formatter: function (value, row, index) {
                        if (row.cateComment > 0)
                            return (row.cateGood / row.cateComment * 100).toFixed(2) + "%";
                        return "0.00%";
                    }
                },
                {
                    field: 'cateTime',
                    title: '工作时长'
                },
                {
                    field: 'userId',
                    title: '用户ID',
                    visible: false
                },
                {
                    field: 'userName',
                    title: '用户名',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        if (row.id != null) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                            return actions.join('');
                        } else {
                            var actions = [];
                            actions.push('<a class="btn btn-warning btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="submitHandler(' + row.userId + ',' + row.cateId + ',\'' + row.cateName + '\')"><i class="fa fa-edit"></i>生成</a> ');
                            return actions.join('');
                        }
                    }
                }]
        };
        $.table.init(options);
    });

    function submitHandler(userId, cateId, cateName) {
        $.operate.submit(prefix + "/my_cate_add", "post", "json", {'userId': userId, 'cateId': cateId, 'cateName': cateName}, $.table.refresh());
    }
</script>
</body>
</html>